#pragma once

#define COMM_NO_ERROR			0
#define COMM_BAD_PARAMS			1
#define COMM_CANNOT_OPEN		2
#define COMM_NOT_OPENED			3
#define COMM_ALREADY_OPEN		4
#define COMM_INVALID_PARAMS		5
#define COMM_INVALID_COMMAND	6

class Comm
{
private:
	HANDLE			_hCom;
	int				_iBufferSize;

public:
	Comm(void);
	virtual ~Comm(void);

	int open(int iPort=1, int iBaud=BAUD_9600, int iBit=DATABITS_8, int iParity=NOPARITY, int iStopBit=ONESTOPBIT);
	int close();

	int setTimeOut(int iTimeOut=100);
	int changeParameters(int iBaud, int iBit, int iParity, int iStopBit);

	int sendData(const void *pData, size_t iLen, size_t *iSendedLen);
	int receiveData(void *pData, size_t iMaxLen, size_t *iReceivedLen);
};

